<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<body>
<script>
function chk_del(){
	var flag = confirm("영구적으로 삭제됩니다. 삭제하시겠습니까?");
	if(flag){
		return true;
	}else{
		return false;		
	}
}
function chk_event(){
	var flag = confirm("이벤트 상품으로 등록됩니다. 진행하시겠습니까? 이벤트 상품은 기획관리에서 확인하실 수 있습니다.");
	if(flag){
		return true;
	}else{
		return false;		
	}
}
</script>
<h2 align="center">컴퓨터 목록</h2>
<table>
	<tr align="center" bgcolor="#BDBDBD">
		<td></td>
		<td width="65">컴퓨터ID</td>
		<td width="90">이름</td>
		<td width="90">가격</td>
		<td width="50">수량</td>
		<td width="600">상세설명</td>
		<td width="50">수정</td>
		<td width="50">삭제</td>
		<td width="55">이벤트</td>
	</tr>
<c:forEach items="${requestScope.computer_list}" var="completePCResult">
	<tr align="center">
		<td width="90" height="90">
		<c:choose>
			<c:when test="${completePCResult.fileName!=null }">
				<img src="/droowa/product-img/${completePCResult.fileName}" style="width:90px; height=90px;">
			</c:when>
			<c:when test="${completePCResult.fileName==null}">
				<img src="/droowa/product-img/No_image.jpg" style="width:90px; height=90px;">
			</c:when>	
		</c:choose>
		</td>
		<td width="65">${completePCResult.completeId }</td>
		<td width="90">${completePCResult.completeName }</td>
		<td width="90">${completePCResult.completePrice }</td>
		<td width="50">${completePCResult.completeQuantity }</td>
		<td width="600	">
		${completePCResult.mainboardName} / ${completePCResult.cpuName} / ${completePCResult.coolerName} / ${completePCResult.memoryName} / ${completePCResult.graphicName} /
		${completePCResult.hddName} / ${completePCResult.ssdName} / ${completePCResult.dvdName} / ${completePCResult.soundName} / ${completePCResult.powerName} /
		${completePCResult.caseName} / ${completePCResult.osName }
		</td>
		<td>
			<a href="/droowa/product/getCompletePCById.do?completeId=${completePCResult.completeId}">
				<input type="button" value="수정" style="width:50px">
			</a>
		</td>
		<td>
			<a href="/droowa/product/removeCompletePC.do?completeId=${completePCResult.completeId}">
				<input type="button" value="삭제" onclick="return chk_del()" style="width:50px">
			</a>
		</td>
		<td>
			<a href="/droowa/product/setEvent.do?completeId=${completePCResult.completeId}">
				<input type="button" value="이벤트" onclick="return chk_event()" style="width:55px">
			</a>
		</td>
	</tr>
</c:forEach>
</table>
<c:if test="${fn:length(requestScope.computer_list) != 0 }">
<table align="center">
	<tr>
		<td>
<c:choose>
	<c:when test="${requestScope.paging.previousPageGroup}">
		<a href="/droowa/product/computerList.do?page=${requestScope.paging.startPageOfPageGroup-1}">◀</a>
	</c:when>
	<c:otherwise>
		◀
	</c:otherwise>
</c:choose>
<c:forEach begin="${requestScope.paging.startPageOfPageGroup}" end="${requestScope.paging.endPageOfPageGroup}" step="1" var="page">
	<c:choose>
		<c:when test="${page == requestScope.paging.currentPage }">
			<b>${page}</b>
		</c:when>
		<c:otherwise>
			<a href="/${initParam.context_root}/product/computerList.do?page=${page}">${page}</a>
		</c:otherwise>
	</c:choose>
</c:forEach>
<c:choose>
	<c:when test="${requestScope.paging.nextPageGroup}">
		<a href="/${initParam.context_root}/product/computerList.do?page=${requestScope.paging.endPageOfPageGroup+1}">▶</a>
	</c:when>
	<c:otherwise>
		▶
	</c:otherwise>
</c:choose>
		</td>
	</tr>
</table>
</c:if>
<a href="/${initParam.context_root }/product/completePCView.do">완제품 목록 다운로드</a>
</body>
</html>